package wifiunion.com.notice.presenter;

import android.content.Context;


import java.util.HashMap;

import wifiunion.com.notice.ConfigureModel;
import wifiunion.com.notice.Constants;
import wifiunion.com.notice.HomePageDetailContact;

/**
 * Created by Administrator on 2016/11/23.
 */

public class GetFirstScreenPresenter implements HomePageDetailContact.Presenter, HomePageDetailContact.Callback {

    private HomePageDetailContact.GetFirstScreenView mView;
    private Context mContext;
    private ConfigureModel mModel;

    /**
     * 1 获取首屏的消息
     */
    private int mPageType;

    private HashMap<String, Object> param = new HashMap<>();


    public GetFirstScreenPresenter(Context context, HomePageDetailContact.GetFirstScreenView view, int pagetype) {
        mView = view;
        mContext = context;
        mModel = new ConfigureModel();
        mView.setPresenter(this);
        mPageType = pagetype;
    }


    @Override
    public void onSuccess(Object data) {

        switch (mPageType) {
            case 0:
                mView.getFirstScreenuccess(data);
                break;
            case 1:
                mView.getMessageSuccess(data);
                break;
        }
    }

    @Override
    public void onServerFailed(Object errorObj) {

        switch (mPageType) {
            case 0:
                mView.showError(errorObj);
                break;
            case 1:
                mView.getMessageFailed(errorObj);
                break;
        }

    }

    @Override
    public void onNetFailed() {
        switch (mPageType) {
            case 0:
                mView.showError("");
                break;
            case 1:
                mView.getMessageFailed("");
                break;
        }

    }

    @Override
    public void start() {
        HashMap<String, Object> params = new HashMap<String, Object>();
        mModel.loadData(Constants.HTTP_URL_GET_CONFIGURE, params, this);
    }

    @Override
    public void start(HashMap<String, Object> params) {
        mModel.loadData(Constants.HTTP_URL_GET_CONFIGURE, params, this);
    }

    public void getCommunityNotice(HashMap<String, Object> params) {
        mModel.getCommunityNotice(Constants.HTTP_URL_GET_NOTICECONFIGUE, params, this);
    }

    @Override
    public void downloadPercent(long percent) {

    }

    @Override
    public void getPackageSize(long size) {

    }
}
